package com.example.administrator.questionanswer;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;

import com.example.administrator.questionanswer.application.MyApplication;
import com.example.administrator.questionanswer.utils.Const;

import butterknife.ButterKnife;

/**
 * Created by Administrator on 2018/4/5 0005.
 */

public class GuidActivity extends Activity {

    Handler handler;
    SharedPreferences sharedPreferences;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_guid);
        ButterKnife.bind(this);
        MyApplication.getActivies().add(this);
        sharedPreferences = getSharedPreferences(Const.USER_INFO, MODE_PRIVATE);
        final boolean online = sharedPreferences.getBoolean(Const.USER_ONLINE, false);
        handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (online) {
                    startActivity(new Intent(GuidActivity.this, FunctionSelectActivity.class));
                    overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
                    finish();
                } else {
                    startActivity(new Intent(GuidActivity.this, LoginActivity.class));
                    overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
                    finish();
                }


            }
        }, 2000);

    }
}
